﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Tetris
{
    class Drawer
    {

        public void FrameDrawer(GameField field, Frame frame)
        {
            int xPosition = field.StartX - 1;
            int yPosition = field.StartY - 1;
            char[,] consoleFrame = new char[frame.Height, frame.Width];
            for (int i = 0; i < consoleFrame.GetLength(0); i++)
            {
                for (int j = 0; j < consoleFrame.GetLength(1); j++)
                {
                    if (i == frame.Height - 1 || j == 0 || j == frame.Width - 1)
                    {
                        consoleFrame[i, j] = '#';
                    }
                    else
                    {
                        consoleFrame[i, j] = ' ';
                    }
                }
            }

            for (int i = 0; i < consoleFrame.GetLength(0); i++)
            {
                Console.SetCursorPosition(xPosition, yPosition++);
                for (int j = 0; j < consoleFrame.GetLength(1); j++)
                {
                    Console.Write(consoleFrame[i,j]);
                }
            }
        }

        public void DrawFigure(Figures figure)
        {
            Console.ForegroundColor = figure.figurecolor;
            Console.SetCursorPosition(figure.Xfigure, figure.Yfigure);
            Console.WriteLine(figure.figureSymbol);
            Console.ForegroundColor = ConsoleColor.White;
        }

        public void ClearFigure(Figures figure)
        {
            Console.SetCursorPosition(figure.Xfigure, figure.Yfigure);
            Console.WriteLine(' ');
        }

    }
}
